package com.yixing.tech.common.utils;


import org.bouncycastle.util.encoders.Hex;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

public class CryptUtil {
    public static String hamcsha1(String strToSign, String password) {
        SecretKeySpec key = new SecretKeySpec(password.getBytes(), "HmacSHA1");
        try {
            Mac mac = Mac.getInstance("HmacSHA1");
            mac.init(key);
            byte rawHmac[] = mac.doFinal(strToSign.getBytes());
            return new String(Hex.encode(rawHmac)).toUpperCase();
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }
}
